<template>
  <section v-loading="loading" class="cms-body">
    <div class="cms-list-header flex-between">
      <div>
        <el-select v-model="params.goodsState" @change="query">
          <el-option label="优惠券状态" value=""></el-option>
          <el-option label="有效" value="1"></el-option>
          <el-option label="已使用" value="2"></el-option>
          <el-option label="已过期" value="3"></el-option>
        </el-select>
        <cms-input label="优惠券名称" v-model="params.goodsName"></cms-input>
        <cms-input label="优惠券编号" v-model="params.goodsNo"></cms-input>
        <cms-input label="手机号" v-model="params.mobile"></cms-input>
        <cms-input label="电子邮箱" v-model="params.email"></cms-input>
        <el-button @click="query">查询</el-button>
      </div>
    </div>
    <!-- 表格 -->
    <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">
      <el-table-column type="selection" width="65" align="center"></el-table-column>
      <el-table-column prop="id" label="ID" width="140" align="center"></el-table-column>
      <el-table-column prop="goodsName" label="优惠券名称" width="120" align="center"></el-table-column>
      <el-table-column prop="goodsNo" label="优惠券编号" width="120" align="center"></el-table-column>
      <el-table-column prop="userName" label="兑换者" width="120" align="center"></el-table-column>
      <el-table-column prop="email" label="电子邮箱" align="center"></el-table-column>
      <el-table-column prop="mobile" label="手机号" align="center"></el-table-column>
      <el-table-column prop="exchangeDate" label="兑换日期" align="center" width="140"></el-table-column>
      <el-table-column prop="expireDate" label="过期日期" align="center" width="140"></el-table-column>
      <el-table-column prop="goodsNum" label="兑换数量" align="center" ></el-table-column>
      <el-table-column prop="goodsState" label="商品状态 " align="center">
        <div slot-scope="scope">
          <span v-if="scope.row.goodsState==1">有效</span>
          <span v-if="scope.row.goodsState==2">已使用</span>
          <span v-if="scope.row.goodsState==3">已过期</span>
        </div>
      </el-table-column>
      <el-table-column prop="name" label="操作" align="center">
        <div slot-scope="scope">
          <cms-button type="edit" @click.native="routerLink('/exchangeGoods/update','update',scope.row.id)" v-perms="'/exchangeGoods/update'"></cms-button>
          <cms-button type="delete" @click.native="deleteBatch($api.userGoodsDelete,scope.row.id)" v-perms="'/exchangeGoods/delete'"></cms-button>
        </div>
      </el-table-column>
    </el-table>
    <!-- 表格底部 -->
    <div class="cms-list-footer">
      <div class="cms-left"></div>
      <!-- 分页组件 -->
      <cms-pagination :total="total" @change="getPages"></cms-pagination>
    </div>
  </section>
</template>

<script>
  import listMixins from '@/mixins/list'

  export default {
    mixins: [listMixins],
    data() {
      return {
        params: {//只需要业务参数
          pageNo: 1,
          pageSize: 10,
          goodsState: '',
          mobile: '',
          email: '',
          goodsName: ''
        }
      };
    },
    methods: {
      query() {
        this.getTableData(this.params);
      }
    },
    created() {
      this.initTableData(this.$api.userGoodsPageList, this.params);
    }
  };
</script>

<style>

</style>
